Pog Script Structure


Each separate Pog script file defines a Pog package that can contain one or more functions.

A Pog script filename has the extension .Pog, e.g. My_Script.Pog

The structure of a Pog script is common for all Pog scripts. Here's a sample Pog script for a package called iExample.

// Example Pog package

// Package name
package iExample;

// Imports - the other packages we are using in this script.
uses Debug;

// Exports - Functions in this package that other scripts can use.
provides Main;
// Enumerators (optional) - Any enumerators for the script defined here.
enum eSample
{
	SE_First_Enum,
	SE_Second_Enum,
	SE_Final_Enum = 100
};
// Prototypes - Functions defined for use in this package.
prototype Main();

// Code starts here

Main()
{
    int count;

    for ( count = 0 ; count < 10 ; ++count )
    {
        debug Debug.PrintString("This is an example\n");
    }
}
// END OF FILE

 

Package Name

package iExample;

The script starts with the package name. This is the filename the script's package will use when it's compiled, with the .pgk extension added, e.g. iexample.pkg, and will also be the prefix for any exported functions if they are used in other scripts, e.g. iExample.Main()

The package name must be unique.

Imports

uses iDebug;

Following the package name is the uses section. This is a comma separated list of other packages that are used in the script. It's essential that you include all the packages your script uses, otherwise the script will fail to compile.

In our example the script uses one package only - the Debug package.

Exports

provides Main;

The Pog script makes available its functions for use by other scripts in the provides section. At least one function in each package must be exported, otherwise there will be no way to access any functions in your package.

Any exported functions will also need to be included in the packages header file, if you wish to compile other scripts that use those functions.  See the Header Files section for more information.

Note that you don't specify any of the function's arguments when you export it.

Enumerators

enum eSample
{
	SE_First_Enum,
	SE_Second_Enum,
	SE_Final_Enum = 100
};

Optionally, following the provides section, Any enumerators may be defined. See the Enumerators section for more details.

 

Prototypes

prototype Main();

A function prototype is similar to a C function prototype û it informs the compiler of the name, type and arguments of a function before the function is properly defined. It is good practice to prototype every function in a package, as this provides the package with an easy to find quick reference list to all the functions in the package.

If you wish to reference a non-prototyped function in another function of your script you will need to make sure the function definition is defined before the function is called in the script. Otherwise the script will generate an error when compiled. This is another good reason to prototype all of your functions.

Code Block

The final section of the script is the code block where the script's functions are defined. In our example we have one function containing a simple for-next loop which prints the same debug message ten times.

See the Functions, prototypes and function calls section for details of function structure.